package tk.mybatis.springboot.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import tk.mybatis.springboot.model.Course;
import tk.mybatis.springboot.model.CourseSession;
import tk.mybatis.springboot.model.StudentCourse;
import tk.mybatis.springboot.model.Students;
import tk.mybatis.springboot.result.Result;
import tk.mybatis.springboot.service.CourseService;

import java.util.List;

@RestController
@RequestMapping("/course")
public class CourseController {

    @Autowired
    private CourseService courseService;

    @PostMapping("/getMyCourse")
    public Result<Object> getMyCourse(@RequestBody Students students) {
        List<Course> course = courseService.getMyCourse(students);
        return  Result.success(course);
    }

    @PostMapping("/getCourseSession")
    public Result<Object> getCourseSession(@RequestBody Course Course) {
        List<CourseSession> course = courseService.getCourseSession(Course.getCourseName());
        return  Result.success(course);
    }

    @PostMapping("/signUp")
    public Result<Object> signUp(@RequestBody StudentCourse studentCourse) {
        return  Result.success(courseService.signUp(studentCourse,false));
    }
    @PostMapping("/signUp2")
    public Result<Object> signUp2(@RequestBody StudentCourse studentCourse) {
        return  Result.success(courseService.signUp(studentCourse,true));
    }


}
